package com.madi.company.presenter;

import com.jaydenxiao.common.baserx.RxSubscriber;
import com.madi.company.bean.SearchResumeEntity;
import com.madi.company.contract.SearchResumeContract;

import java.util.Map;

/**
 * Created by 丁宁
 * on 2017/2/14.
 */

public class SearchResumePresenter extends SearchResumeContract.Presenter {

    @Override
    public void getData(Map<String, String> map, final String refreshOrLoadMore) {
        boolean mIsLoading;
        if (refreshOrLoadMore.equals("")){
            mIsLoading = true;
        }else {
            mIsLoading = false;
        }
        mRxManage.add(mModel.getResumeData(map).subscribe(new RxSubscriber<SearchResumeEntity>(mContext,mIsLoading) {
            @Override
            protected void _onNext(SearchResumeEntity list) {

                if (refreshOrLoadMore.equals("1")){
                    mView.returnRefreshResumeData(list);
                }else if (refreshOrLoadMore.equals("2")){
                    mView.returnLoadMoreResumeData(list);
                }else {
                    mView.returnResumeData(list);
                }
                mView.stopLoading();
            }

            @Override
            protected void _onError(String message) {
                mView.stopLoading();
            }
        }));
    }
}
